const path=require('path');
const HtmlPlugin=require('html-webpack-plugin');
const UglifyjsPlugin=require('uglifyjs-webpack-plugin');
const CleanPlugin=require('clean-webpack-plugin');

module.exports={
    mode: 'development',
    entry: './src/main.js',
    output:{
        filename: 'app.[hash].js',
        path: path.resolve(__dirname, 'dist')
    },
    module:{
        rules:[
            {
                test:/\.styl/,
                use:['style-loader', 'css-loader', 'stylus-loader']
            },
            {
                test:/\.(sa|sc|c)ss/,
                use:['style-loader', 'css-loader', 'sass-loader'],
            }
        ]
    },
    plugins:[
        new HtmlPlugin({
            template: path.resolve(__dirname, 'src/index.html')
        }),
        new UglifyjsPlugin(),   //丑化JS
        new CleanPlugin(),      //删除旧版本
    ],
    devServer:{
        port: 9090,
        open: true,
    }
}
